package com.bdqn.service;

import com.bdqn.dao.UserDao;
import com.bdqn.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 用户模块业务层实现
 */
@Service("userService")
public class UserServiceImpl implements UserService {
    //实例化所依赖的UserDao对象
//    @Resource
    @Resource(name="userDao")
//    @Resource(type = UserDaoImpl.class)
//    @Autowired
    private  UserDao dao;

    public UserServiceImpl(){
    }

    //用于为Dao属性赋值的构造方法
    public UserServiceImpl(UserDao dao){
        this.dao=dao;
    }

    /**
     * 保存用户信息
     * @param user
     */
    @Override
    public void save(User user) {
        //调用UserDao的方法保存用户信息

        dao.save(user);
    }


    public void setUserDao(UserDao dao){
        this.dao=dao;
    }

}
